<?php
session_start();

include_once 'recursos/config.php';
$conf = new configuracion();
$dominio = $conf->getG2uDominio()."/";

$cant_comment = "No hay comentarios";
$who_comment = "";
$temp = "";

if (is_array($_SESSION["g2uActualPhotoComment"]) && !empty($_SESSION["g2uActualPhotoComment"])) {
    $cant_comment = count($_SESSION["g2uActualPhotoComment"]);
    $cant_comment .= " <img src=\'".$dominio."images/png/comentario.png\' />";
    
    foreach ($_SESSION["g2uActualPhotoComment"] as $key => $value) {
        $temp[$value['uname']] = $value['uname'];
    }

    foreach ($temp as $key => $v) {
        $who_comment .= $v."<br/>";
    }
}

?>
<script>
    $(document).ready(function(){
        $("#c_cont").html('<span title="<?=$who_comment?>" alt="<?=$who_comment?>"> <?=$cant_comment?> </span>');
        $('span').tipsy({html: true });
    });

</script>

<form action="<?=$dominio?>upload.php" method="post" target="uploadResult" enctype="multipart/form-data" id="uploadForm" onsubmit="return validarForm();">
    <table>
        <tr>
            <td rowspan="2">
                <textarea id="comentario" name="comentario" rows="4" cols="30" required="required"></textarea> 
                <input type="hidden" id="lat" name="lat" value="" />
                <input type="hidden" id="long" name="long" value="" />
                <input type="hidden" id="acc" name="acc" value="" />
                <input type="hidden" id="wishlist" name="wishlist" value="1" />
                <input type="hidden" id="evento" name="evento" value="<?=$_REQUEST["eid"]?>" />
            </td>
            <td>
                <img src="<?=$dominio?>images/png/camara.png" width="16" />:<input type="file" name="file" id="file" required="required">
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" name="submit" value="Postear" id="Postear">
                <iframe id="uploadResult" name="uploadResult" width="100%" height="20px" style="border-width: 0px;"></iframe>
            </td>
        </tr>
    </table>
</form>

<?

if (is_array($_SESSION["g2uActualPhotoComment"]) && !empty($_SESSION["g2uActualPhotoComment"])) {
    foreach ($_SESSION["g2uActualPhotoComment"] as $key => $value) {
?>
        <table width='100%' cellpadding = '3px' cellspacing="0">
            <tr>
                <td width='36px'>
                    <img src='<?=$dominio.$value["upic"]?>' width='36px' />
                </td>
                <td>
                    <b><?=$value['uname']?></b>  <br/>
                       <?=htmlspecialchars($value['desc'])?>         <br/>
                    <i><?=$value['fecha']?> </i>
                </td>
            </tr>
        </table>
<?php
    }
} else {
    ?>
    S&eacute; el primero en comentar!
    <?php
}
?>